var mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/test');

var schema = mongoose.Schema;

var newsInfoSchema = new schema({
    id:{
        type:Number,
        required:true
    },
    title:{
        type:String,
        required:true
    },
    add_time:{
        type:String,
        required:true
    },
    content:{
        type:String,
        required:true
    },
    click:{
        type:String,
        required:true
    },

});
var newsinfo = mongoose.model('newinfo',newsInfoSchema);

/*var admin = new newsinfo({
    id:1,
    title: "震惊！！！南京晓庄学院一男子随地大小便",
    add_time:'2018-03-11',
    content: '哈哈哈',
    click: '999+',
 })
var admin1 = new newsinfo({
    id:2,
    title: "震惊！！！南京晓庄学院一女子半夜发痴",
    add_time:'2018-03-12',
    content: '哈哈哈',
    click: '10000+',
});

admin.save(function (err, ret) {
  if (err) {
    console.log('保存失败')
  } else {
    console.log('保存成功')
    console.log(ret)
  }
});
admin1.save(function (err, ret) {
    if (err) {
        console.log('保存失败')
    } else {
        console.log('保存成功')
        console.log(ret)
    }
});*/
module.exports = newsinfo;